home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / OS / FWGraphx / Sources / FWArcShp.cpp next >
Encoding:
Text File  |  1994-04-21  |  9.3 KB  |  320 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWArcShp.cpp
  4. //    Release Version:    $ 1.0d1 $
  5. //
  6. //    Creation Date:        3/28/94
  7. //
  8. //    Copyright:    © 1993, 1994 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef FWARCSHP_H
  13. #include "FWArcShp.h"
  14. #endif
  15.  
  16. #ifndef FWSHAPE_H
  17. #include "FWShape.h"
  18. #endif
  19.  
  20. #ifndef FWGC_H
  21. #include "FWGC.h"
  22. #endif
  23.  
  24. #ifndef FWDFAULT_H
  25. #include "FWDfault.h"
  26. #endif
  27.  
  28. #ifndef FWOVLSHP_H
  29. #include "FWOvlShp.h"
  30. #endif
  31.  
  32. #ifndef FWRRCSHP_H
  33. #include "FWRRcShp.h"
  34. #endif
  35.  
  36. #ifndef FWRECSHP_H
  37. #include "FWRecShp.h"
  38. #endif
  39.  
  40. #ifndef FWLINSHP_H
  41. #include "FWLinShp.h"
  42. #endif
  43.  
  44. #ifndef FWRGNSHP_H
  45. #include "FWRgnShp.h"
  46. #endif
  47.  
  48. // ----- OpenDoc Includes -----
  49.  
  50. #ifndef _TRNSFORM_
  51. #include <Trnsform.h>
  52. #endif
  53.  
  54. //==============================================================================
  55. //    •• RunTime Info
  56. //==============================================================================
  57.  
  58. #ifdef FW_BUILD_MAC
  59. #pragma segment fwgraphx
  60. #endif
  61.  
  62. //==============================================================================
  63. //    •• class FW_CArcShape
  64. //==============================================================================
  65.  
  66. //------------------------------------------------------------------------------
  67. // FW_CArcShape::FW_CArcShape
  68. //------------------------------------------------------------------------------
  69.  
  70. FW_CArcShape::FW_CArcShape() :
  71.     FW_CShape()
  72. {
  73. }
  74.  
  75. //------------------------------------------------------------------------------
  76. // FW_CArcShape::FW_CArcShape
  77. //------------------------------------------------------------------------------
  78.  
  79. FW_CArcShape::FW_CArcShape(const FW_CRect& rect, short startAngle, short arcAngle) :
  80.     FW_CShape()
  81. {
  82.     SetRep(new FW_CArcShapeRep(rect, startAngle, arcAngle));
  83. }
  84.  
  85. //------------------------------------------------------------------------------
  86. // FW_CArcShape::FW_CArcShape
  87. //------------------------------------------------------------------------------
  88.  
  89. FW_CArcShape::FW_CArcShape(const FW_CArcShape& other) :
  90.     FW_CShape(other)
  91. {
  92. }
  93.  
  94. //------------------------------------------------------------------------------
  95. // FW_CArcShape::FW_CArcShape
  96. //------------------------------------------------------------------------------
  97.  
  98. FW_CArcShape::FW_CArcShape(FW_CArcShapeRep* rep) :
  99.     FW_CShape(rep)
  100. {
  101. }
  102.  
  103. //------------------------------------------------------------------------------
  104. // FW_CArcShape::operator=
  105. //------------------------------------------------------------------------------
  106.  
  107. FW_CArcShape& FW_CArcShape::operator=(const FW_CArcShape& other)
  108. {
  109.     SetRep(other.GetRep());
  110.     return *this;
  111. }
  112.  
  113. //------------------------------------------------------------------------------
  114. // FW_CArcShape::operator=
  115. //------------------------------------------------------------------------------
  116.  
  117. FW_CArcShape& FW_CArcShape::operator=(FW_CArcShapeRep* other)
  118. {
  119.     SetRep(other);
  120.     return *this;
  121. }
  122.  
  123. //------------------------------------------------------------------------------
  124. // FW_CArcShape::operator FW_COvalShape
  125. //------------------------------------------------------------------------------
  126.  
  127. FW_CArcShape::operator FW_COvalShape() const
  128. {    
  129.     FW_COvalShape ovalShape(((FW_CShapeRep*)GetRep())->GetShapeBounds());
  130.     ovalShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
  131.     return ovalShape;
  132. }
  133.  
  134. //------------------------------------------------------------------------------
  135. // FW_CArcShape::operator FW_CRoundRectShape
  136. //------------------------------------------------------------------------------
  137.  
  138. FW_CArcShape::operator FW_CRoundRectShape() const
  139. {    
  140.     FW_CRoundRectShape roundRectShape(((FW_CShapeRep*)GetRep())->GetShapeBounds(), FW_kZeroPoint);
  141.     roundRectShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
  142.     return roundRectShape;
  143. }
  144.  
  145. //------------------------------------------------------------------------------
  146. // FW_CArcShape::operator FW_CRectShape
  147. //------------------------------------------------------------------------------
  148.  
  149. FW_CArcShape::operator FW_CRectShape() const
  150. {    
  151.     FW_CRectShape rectShape(((FW_CShapeRep*)GetRep())->GetShapeBounds());
  152.     rectShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
  153.     return rectShape;
  154. }
  155.  
  156. //------------------------------------------------------------------------------
  157. // FW_CArcShape::operator FW_CLineShape
  158. //------------------------------------------------------------------------------
  159.  
  160. FW_CArcShape::operator FW_CLineShape() const
  161. {    
  162. //    NotYetImplemented();
  163.  
  164.     FW_CRect rect = ((FW_CShapeRep*)GetRep())->GetShapeBounds();
  165.     FW_CLineShape lineShape(rect[FW_kTopLeft], rect[FW_kBotRight]);
  166.     lineShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
  167.     return lineShape;
  168. }
  169.  
  170. //------------------------------------------------------------------------------
  171. // FW_CArcShape::operator FW_CRegionShape
  172. //------------------------------------------------------------------------------
  173.  
  174. FW_CArcShape::operator FW_CRegionShape() const
  175. {    
  176. //    NotYetImplemented();
  177.     
  178.     FW_CRegionShape regionShape(((FW_CShapeRep*)GetRep())->GetShapeBounds());
  179.     regionShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
  180.     return regionShape;
  181. }
  182.  
  183. //==============================================================================
  184. //    •• class FW_CArcShapeRep
  185. //==============================================================================
  186.  
  187. //------------------------------------------------------------------------------
  188. //    • FW_CArcShapeRep::FW_CArcShapeRep
  189. //------------------------------------------------------------------------------
  190.  
  191. FW_CArcShapeRep::FW_CArcShapeRep() :
  192.     FW_CBoundedShapeRep(gGraphicGlobales.gArc, FW_CRect(0,0,0,0)),
  193.     fStartAngle(0),
  194.     fArcAngle(0)
  195. {
  196. }
  197.  
  198. //------------------------------------------------------------------------------
  199. //    • FW_CArcShapeRep::FW_CArcShapeRep
  200. //------------------------------------------------------------------------------
  201.  
  202. FW_CArcShapeRep::FW_CArcShapeRep(const FW_CRect& rect, short startAngle, short arcAngle) :
  203.     FW_CBoundedShapeRep(gGraphicGlobales.gArc, rect),
  204.     fStartAngle(startAngle),
  205.     fArcAngle(arcAngle)
  206. {
  207. }
  208.  
  209. //------------------------------------------------------------------------------
  210. //    • FW_CArcShapeRep::~FW_CArcShapeRep
  211. //------------------------------------------------------------------------------
  212.  
  213. FW_CArcShapeRep::~FW_CArcShapeRep()
  214. {
  215. }
  216.  
  217. //------------------------------------------------------------------------------
  218. //    • FW_CArcShapeRep::Draw
  219. //------------------------------------------------------------------------------
  220.  
  221. void FW_CArcShapeRep::Draw(FW_CGraphicContext* graphicContext)
  222. {    
  223.     FW_ShapeFills shapeFill = GetShapeFill();
  224.  
  225.     if (shapeFill == FW_kNullShape)
  226.         return;
  227.         
  228.     graphicContext->SelectInkAndStyle(GetShapeInk(), GetShapeStyle(), FW_kGeometricShape, shapeFill);
  229.  
  230.     FW_SPlatformRect rect = graphicContext->AsPlatformRect(fRect);
  231.  
  232. #ifdef FW_BUILD_MAC
  233.     if (shapeFill == FW_kFramed)
  234.         ::FrameArc(&rect, fStartAngle, fArcAngle);
  235.     else
  236.         ::PaintArc(&rect, fStartAngle, fArcAngle);
  237. #endif
  238. #ifdef FW_BUILD_WIN
  239. #endif
  240. }
  241.  
  242. //------------------------------------------------------------------------------
  243. //    • FW_CArcShapeRep::DrawArc
  244. //------------------------------------------------------------------------------
  245.  
  246. void FW_CArcShapeRep::DrawArc(FW_CGraphicContext* graphicContext,
  247.                             const FW_CRect& rect,  short startAngle, short arcAngle)
  248. {    
  249.     if (gGraphicGlobales.gArc.fFill == FW_kNullShape)
  250.         return;
  251.  
  252.     graphicContext->SelectInkAndStyle(gGraphicGlobales.gArc.fInk, 
  253.                                         gGraphicGlobales.gArc.fStyle, 
  254.                                         FW_kGeometricShape, 
  255.                                         gGraphicGlobales.gArc.fFill);
  256.  
  257.     FW_SPlatformRect qdRect = graphicContext->AsPlatformRect(rect);
  258.  
  259. #ifdef FW_BUILD_MAC
  260.     if (gGraphicGlobales.gArc.fFill == FW_kFramed)
  261.         ::FrameArc(&qdRect, startAngle, arcAngle);
  262.     else
  263.         ::PaintArc(&qdRect, startAngle, arcAngle);
  264. #endif
  265. #ifdef FW_BUILD_WIN
  266. #endif
  267. }
  268.  
  269. //------------------------------------------------------------------------------
  270. //    • FW_CArcShapeRep::Copy
  271. //------------------------------------------------------------------------------
  272.  
  273. FW_CArcShape FW_CArcShapeRep::Copy() const
  274. {
  275.     FW_CArcShape arcShape(fRect, fStartAngle, fArcAngle);
  276.     return arcShape;
  277. }
  278.  
  279. //------------------------------------------------------------------------------
  280. //    • FW_CArcShapeRep::SetAsDefault
  281. //------------------------------------------------------------------------------
  282.  
  283. void FW_CArcShapeRep::SetAsDefault() const
  284. {
  285.     SetDefaultProperties(gGraphicGlobales.gArc);
  286. }
  287.  
  288. //------------------------------------------------------------------------------
  289. //    • FW_CArcShapeRep::HitTest
  290. //------------------------------------------------------------------------------
  291.  
  292. FW_HitTestPart FW_CArcShapeRep::HitTest(const FW_CPoint& test) const
  293. {
  294.     return FW_kOutside;
  295. }
  296.  
  297. //----------------------------------------------------------------------------------------
  298. //    • FW_CArcShapeRep::Flatten
  299. //----------------------------------------------------------------------------------------
  300.  
  301. void FW_CArcShapeRep::Flatten(FW_CWritableStream& stream)
  302. {
  303.     FW_CBoundedShapeRep::Flatten(stream);
  304.     stream << fStartAngle;
  305.     stream << fArcAngle;
  306. }
  307.  
  308. //----------------------------------------------------------------------------------------
  309. //    • FW_CArcShapeRep::Unflatten
  310. //----------------------------------------------------------------------------------------
  311.  
  312. void FW_CArcShapeRep::Unflatten(FW_CReadableStream& stream)
  313. {
  314.     FW_CBoundedShapeRep::Unflatten(stream);
  315.     stream >> fStartAngle;
  316.     stream >> fArcAngle;
  317. }
  318.  
  319.  
  320.